<?php
//长文本编辑器页



include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/forum/inc.php");
error_reporting(E_ERROR | E_PARSE);


//所有的参数
$g_cgival 	= array();
//存储中间数据 非输出数据 可以不用
$g_pro	 	= array();
//要显示的数据 输出数据
$g_show 	= array();

function check_cgi_pro()
{		
	global $g_cgival, $g_pro, $g_show, $config;

	//板块id
	cgi::both($g_cgival["text_id"], "id", 0);
	cgi::both($g_cgival["f_id"], "fid", 0);
}


function get_data()
{
	global $g_cgival, $g_pro, $g_show, $config;
	
	//get data
	$text_id = $g_cgival["text_id"];
	$f_id = $g_cgival["f_id"];
	
	if($text_id)
	{
		//text info
		$db_long_text_info = new db_long_text_info();
		$text_info = $db_long_text_info->get_item_by_id($text_id);
		
		//text content
		$db_long_text_content = new db_long_text_content();
		$text_content = $db_long_text_content->get_item_by_tid($text_id);
		$f_id = $text_info["f_id"];
		
	}
	else
	{
		if(!$f_id)
		{
			throw new Exception("f_id不能为空！");
		}
		
	}
	//get forum class info 
	$db_forum_class = new db_forum_class();
	$g_show["forum_class"] = $db_forum_class->get_list_by_f_id($f_id);
	
	
}

try {
	$g_show['error'] = 0;
	$g_show['errmsg'] = "";
	check_cgi_pro();
	get_data();
	
} catch (Exception $e) {
	$g_show['error'] = 1;
	$g_show['errmsg'] = $e->getMessage();
}

show_pro();

exit;

function show_pro()
{
	global $g_cgival, $g_pro, $g_show, $config;

	$smarty = p_get_smarty();	
	$smarty->assign("g_show", $g_show);
	if (isset($_GET["debug"]))
	{
		print_r($g_show);
	}
	if($g_show["error"])
	{
		
		$smarty->display("error.html");
	}
	else
	{
		$smarty->display("forum/ledit.html");
	}
	
	
	unset($g_cgival);
	unset($g_pro);
	unset($g_show);
	unset($config);
	
}

